<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<base href="<%=basePath%>">

<html>
    <head>
        <meta charset="utf-8">
        <title>
            阳光成单系统
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="System/css/x-admin.css" media="all">
    </head>
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>货物管理</cite></a>
              <a><cite>货物分类管理</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
        </div>
        <div class="x-body">
            <xblock><button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon">&#xe640;</i>批量禁用</button><span class="x-right" style="line-height:40px">共有数据：${count} 条</span></xblock>
<%--            <button class="layui-btn" onclick="kiss_add('添加事件','kiss-add.jsp','','400')"><i class="layui-icon">&#xe608;</i>添加</button>--%>
            <table class="layui-table">
                <thead>
                    <tr>
                        <th>
                            <input type="checkbox" name="" value="">
                        </th>
                        <th>
                            ID
                        </th>
                        <th>
                            货物类型
                        </th>
                        <th>
                            状态
                        </th>
                        <th>
                            操作
                        </th>
                    </tr>
                </thead>
                <tbody id="tbody">
                <c:forEach items="${allgoodsType}" var="a">
                    <tr>
                        <td>
                            <input type="checkbox" value="${a.goodstypeId}" name="">
                        </td>
                        <td>
                            ${a.goodstypeId}
                        </td>
                        <td>
                            ${a.goodstypeType}
                        </td>
                        <td >
                            <span class="layui-btn layui-btn-normal layui-btn-mini">
                            ${a.goodstypeCode==0?"未使用":"正在使用"}
                            </span>
                        </td>
                        <td class="td-manage">
<%--                            <a title="编辑" href="javascript:;" onclick="kiss_edit('编辑','kiss-edit.jsp','4','','300')"--%>
<%--                            style="text-decoration:none">--%>
<%--                                <i class="layui-icon">&#xe642;</i>--%>
<%--                            </a>--%>
                                <button type="button" style="background-color: red; color: white; border: 0px; cursor: pointer " onclick="upwarecode(${a.goodstypeId},${a.goodstypeCode})">
                                <i class="layui-icon">禁用/启用&#xe640;</i>
                                </button>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
        <script src="System/lib/layui/layui.js" charset="utf-8"></script>
        <script src="System/js/x-layui.js" charset="utf-8"></script>
        <script>
            layui.use(['element','layer'], function(){
                $ = layui.jquery;//jquery
              lement = layui.element();//面包导航
              layer = layui.layer;//弹出层


            })

              
            //批量删除提交
             function delAll () {
                 var checks = $('#tbody').find('input[type=checkbox]:checked');
                 var str="";
                 for (var i = 0; i < checks.length; i++) {
                     str+=checks[i].value+",";
                 }
                 layer.confirm('确认禁用选择的货物类别吗?',function(index){
                     //捉到所有被选中的，发异步进行删除  提示
                     // layer.msg('操作成功!', {icon: 1});
                     //ajax请求   软删除选中文章数据
                     $.post("goodstype/upGoodsTpyeAll", {str:str}, function (date) {
                         alert(date);
                         window.location.reload();
                     });
                 });
             }
            // 等级-增加
            function kiss_add (title,url,id,w,h) {
                x_admin_show(title,url,w,h); 
            }
            // 等级-编辑
            function kiss_edit (title,url,id,w,h) {
                x_admin_show(title,url,w,h); 
            }
           
            /*等级-删除*/
            function kiss_del(obj,id){
                layer.confirm('确认要删除吗？',function(index){
                    //发异步删除数据
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
                });
            }
            </script>

           <script>
               function upwarecode(id,code){
                   if(code==0){
                       layer.confirm('是否启用该货物类别',function(index){
                           $.post("goodstype/upGoodsTypeUp", {id:id}, function () {
                               alert("启用成功！");
                               window.location.reload();
                           });
                       });
                   }else if(code==1){
                       layer.confirm('是否禁用该货物类别',function(index){
                           $.post("goodstype/upGoodsTypeDonw", {id:id}, function (date) {
                               alert(date);
                               window.location.reload();
                           });
                       });
                   }
               }
           </script>
    </body>
</html>